<template>
	<view class="inwardPlan">
		<uni-nav-bar color="#ffffff" background-color="#00aded" :statusBar="true" title="调拨-制作派车单" fixed="true" left-icon="left" left-text="返回" @clickLeft="back" />
		<view class="inwardPlan_top">
			<!-- 搜索 -->
			<dil-search :columnData="options.columnDataList" @onSearch="onSearch" v-if="options.columnDataList.length > 0"></dil-search>
		</view>
		<view class="inwardPlan_main">
			<dil-card class="dilCard" @emitEvent="emitEvent" v-bind.sync="options"></dil-card>
		</view>
		<view class="inwardPlan_floot"></view>
	</view>
</template>

<script>
import { mapMutations } from 'vuex';
export default {
	data() {
		return {
			options: {
				requestUrl: '/api/v1/ams/getProductPlanList?apiId=626',
				requestQuery: {},
				cardSlotList: [
					{
						label: '派车',
						icon: 'wlIcon-paicheguanli',
						emitEvent: 'transOrderAdd'
					},
					{
						label: '运单详情',
						icon: 'bars',
						emitEvent: 'transOrderDetails'
					}
				],
				columnDataList: [],
				totalNum: 0,
				rowDataList: []
			}
		};
	},
	onShow() {
		uni.$emit('onShow', 1);

		this.getOrderSection();
	},
	mounted() {
		this.getOrderSectionDebounce = this.Tool.debounce((data) => {
			this.getOrderSection(data);
		}, 1500);
	},
	methods: {
		async getOrderSection(data = {}) {
			data.deleted = 4;
			this.options.requestQuery = { ...data };
		},
		onSearch(item) {
			this.getOrderSectionDebounce(item);
		},
		back() {
			uni.switchTab({
				url: '/pages/index/index'
			});
		},
		emitEvent(eventName, cardItem) {
			this[eventName](cardItem);
		},
		transOrderAdd(item) {
			this.updateInwardTransOrderItem(item);
			uni.navigateTo({
				url: '/pages/transOrder/inwardTransOrderAdd'
			});
		},
		transOrderDetails(item) {
			uni.navigateTo({
				url:
					'/pages/transOrder/inwardTransOrder?params=' +
					JSON.stringify({
						planId: item.transPlanId
					})
			});
		},
		//vuex
		...mapMutations('inward', ['updateInwardTransOrderItem'])
	}
};
</script>

<style lang="scss" scoped>
.inwardPlan {
	width: 100vw;
	height: 100%;
	background-color: #f5f5f5;
	&_top {
		background-color: #fff;
	}
	&_main {
	}
	&_floot {
	}
}
</style>
